/**
 * Created by Administrator on 2016/12/21.
 */
define('wraps', ['jquery'], function($) {
    var centent=$("#centent");
    $('#aside').click(function()
    {
        if(centent.hasClass("aside")){
            if(centent.hasClass("hidden")){
                centent.removeClass("hidden");
                centent.toggleClass("fadeOutLeft");
            }
            else{
                centent.toggleClass("fadeOutLeft");
                centent.addClass('hidden');
            }
        }
    });
    //第三种兼容
    var EventUtil = {
        addHandler: function (oElement, sEvent, fnHandler) {
            oElement.addEventListener ? oElement.addEventListener(sEvent, fnHandler, false) : oElement.attachEvent("on" + sEvent, fnHandler)
        },
        removeHandler: function (oElement, sEvent, fnHandler) {
            oElement.removeEventListener ? oElement.removeEventListener(sEvent, fnHandler, false) : oElement.detachEvent("on" + sEvent, fnHandler)
        },
        addLoadHandler: function (fnHandler) {
            this.addHandler(window, "load", fnHandler)
        }
    };
    EventUtil.addHandler(window,"scroll",function () {
        var top = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
        var clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
        var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
        if(scrollHeight<3000){
            if (top + clientHeight == scrollHeight) {
                var h=$('#wrap').css('height').split('px');
                var s=parseInt(h[0])+500;
                $('#wrap').css('height',s+"px")
            }
        }
    })
});
// 使用
// 加载模块

module.exports = function(ngModule) {
    require('./wraps.scss');
    ngModule.directive('wraps',function () {
        return {
            restrict: 'E',//元素(element)
            scope: {},
            replace: true,
            template: require('./wraps.html'),//模板
            controllerAs: '',// <=> $scope.vm = {greeting: '你好，我是卡哥'}
            controller: function () {
            }
        }
    });//定义指令，对应页面中的<hello-world></hello-world>
    require(['wraps'], function (my){
    });
}